home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 12 - 1996 / 12.03 Mar 96 / PPTextEdit ƒ / PPTextEdit.cp next >
Encoding:
Text File  |  1996-01-04  |  3.8 KB  |  149 lines  |  [TEXT/CWIE]

  1. // ===========================================================================
  2. //    <PP Starter Source>.cp         ©1994-1995 Metrowerks Inc. All rights reserved.
  3. // ===========================================================================
  4. //
  5. //    This file contains the starter code for a PowerPlant application
  6.  
  7. #include "PPTextEdit.h"
  8.  
  9. #include <LGrowZone.h>
  10. #include <LWindow.h>
  11. #include <PP_Messages.h>
  12. #include <PP_Resources.h>
  13. #include <PPobClasses.h>
  14. #include <UDrawingState.h>
  15. #include <UMemoryMgr.h>
  16. #include <URegistrar.h>
  17. #include <LEditField.h>
  18.  
  19. // put declarations for resource ids (ResIDTs) here
  20.  
  21. const ResIDT    window_Sample        = 1000;    // EXAMPLE
  22.  
  23.  
  24. // ===========================================================================
  25. //        • Main Program
  26. // ===========================================================================
  27.  
  28. void main(void)
  29. {
  30.                                     // Set Debugging options
  31.     SetDebugThrow_(debugAction_Alert);
  32.     SetDebugSignal_(debugAction_Alert);
  33.  
  34.     InitializeHeap(3);                // Initialize Memory Manager
  35.                                     // Parameter is number of Master Pointer
  36.                                     //   blocks to allocate
  37.     
  38.                                     // Initialize standard Toolbox managers
  39.     UQDGlobals::InitializeToolbox(&qd);
  40.     
  41.     new LGrowZone(20000);            // Install a GrowZone function to catch
  42.                                     //    low memory situations.
  43.  
  44.     CPPStarterApp    theApp;            // replace this with your App type
  45.     theApp.Run();
  46. }
  47.  
  48.  
  49. // ---------------------------------------------------------------------------
  50. //        • CPPStarterApp             // replace this with your App type
  51. // ---------------------------------------------------------------------------
  52. //    Constructor
  53.  
  54. CPPStarterApp::CPPStarterApp()
  55. {
  56.     // Register functions to create core PowerPlant classes
  57.     
  58.     RegisterAllPPClasses();
  59. }
  60.  
  61.  
  62. // ---------------------------------------------------------------------------
  63. //        • ~CPPStarterApp            // replace this with your App type
  64. // ---------------------------------------------------------------------------
  65. //    Destructor
  66. //
  67.  
  68. CPPStarterApp::~CPPStarterApp()
  69. {
  70. }
  71.  
  72. // ---------------------------------------------------------------------------
  73. //        • StartUp
  74. // ---------------------------------------------------------------------------
  75. //    This function lets you do something when the application starts up. 
  76. //    For example, you could issue your own new command, or respond to a system
  77. //  oDoc (open document) event.
  78.  
  79. void
  80. CPPStarterApp::StartUp()
  81. {
  82.     ObeyCommand(cmd_New, nil);        // EXAMPLE, create a new window
  83. }
  84.  
  85. // ---------------------------------------------------------------------------
  86. //        • ObeyCommand
  87. // ---------------------------------------------------------------------------
  88. //    Respond to commands
  89.  
  90. Boolean
  91. CPPStarterApp::ObeyCommand(
  92.     CommandT    inCommand,
  93.     void        *ioParam)
  94. {
  95.     Boolean        cmdHandled = true;
  96.  
  97.     switch (inCommand) {
  98.     
  99.         // Deal with command messages (defined in PP_Messages.h).
  100.         // Any that you don't handle will be passed to LApplication
  101.              
  102.         case cmd_New:
  103.                                         // EXAMPLE, create a new window
  104.             LWindow        *theWindow;
  105.             theWindow = LWindow::CreateWindow(window_Sample, this);    
  106.             theWindow->Show();
  107.             break;
  108.  
  109.  
  110.  
  111.         default:
  112.             cmdHandled = LApplication::ObeyCommand(inCommand, ioParam);
  113.             break;
  114.     }
  115.     
  116.     return cmdHandled;
  117. }
  118.  
  119. // ---------------------------------------------------------------------------
  120. //        • FindCommandStatus
  121. // ---------------------------------------------------------------------------
  122. //    This function enables menu commands.
  123. //
  124.  
  125. void
  126. CPPStarterApp::FindCommandStatus(
  127.     CommandT    inCommand,
  128.     Boolean        &outEnabled,
  129.     Boolean        &outUsesMark,
  130.     Char16        &outMark,
  131.     Str255        outName)
  132. {
  133.  
  134.     switch (inCommand) {
  135.     
  136.         // Return menu item status according to command messages.
  137.         // Any that you don't handle will be passed to LApplication
  138.  
  139.         case cmd_New:                    // EXAMPLE
  140.             outEnabled = true;            // enable the New command
  141.             break;
  142.  
  143.         default:
  144.             LApplication::FindCommandStatus(inCommand, outEnabled,
  145.                                                 outUsesMark, outMark, outName);
  146.             break;
  147.     }
  148. }
  149.